import { _decorator, Component, Node } from 'cc';
import { Dictionary } from '../utils/Dictionary';
import { roleEquipEnum } from '../Enum';
import { StartSceneGameMgr } from './StartSceneGameMgr';
import { Equip } from './Equip';
import { keepOneDecimalFull2 } from '../utils/utils';
import { UserInfo } from './UserInfo';
import { loading } from '../loading';
const { ccclass, property } = _decorator;

@ccclass('Pet')
export class Pet {
   
    petId=null;
    petType;
    petTp:any;
    isGoBattle;
    petLevel;
 
    initData(data) {
        this.petId = data.petId;
        this.petType=data.petType;
        this.petTp = UserInfo.petCongfiDic.get(this.petType);
        this.isGoBattle=data.isGoBattle||false;
        this.petLevel=data.petLevel||1;
    }

    get attackAddition() {
        let res=this.petTp.attack+(this.petLevel*2);
        return res
    }
    get frequencyAddition() {//返回几秒发射一次
        let res=-(this.petTp.frequency);
        return res
    }
    get criticalHitAddition() {//返回暴击率，小数
        let res=this.petTp.criticalHit;
        return res
    }

    get battleValue() {
        let res;
        res = this.petTp.quality*50+this.petLevel*3
        return res
    }

    get nextLevelAttackAddition() {
        let res=this.petTp.attack+((this.petLevel+1)*2);
        return res
    }

    get EnhanceCost(){
        let res;
        res=(this.petLevel+1)*20
        return res;
    }

    get getEnhanceSucceedProbability(){//强化成功概率
        let res=100;

        if (this.petLevel<=5) {
            res=100;
        }
        else {
            res = 100-((this.petLevel-5)*5)//6级，百分之95,7级百分之90，以此类推
        }

        if (res<40) {//最低概率百分之40
            res=40;
        }

        return res
    }

    //得到的分解奖励
    get salvageGet() {
        let res;
        res = (this.petLevel+1)*5 + ((this.petTp.quality+1)*50)
        return res;
    }

}


